using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace ClickNET
{
    public class Log
    {
        static readonly object padlock = new object();

        static Log s_defaultInstance = null;
        public static Log DefaultLog
        {
            get
            {
                lock (padlock)
                {
                    if (null == s_defaultInstance)
                        s_defaultInstance = new Log();

                    return s_defaultInstance;
                }
            }
        }

        public void WriteLine(string line)
        {
            lock (this)
            {
                // create a writer and open the file
                StreamWriter sw;

                sw = File.AppendText("C:\\svn\\clickdotnet\\www\\log.txt");

                // write a line of text to the file
                sw.WriteLine(DateTime.Now + ": " + line);

                // close the stream
                sw.Close();
            }
        }

        public void WriteLine(Exception e)
        {
            WriteLine(e.ToString());
        }
    }
}
